home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bmsf.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  3.5 KB  |  119 lines

  1. /* 
  2.  *
  3.  * $Id: k3bmsf.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003-2007 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef _K3B_MSF_H_
  18. #define _K3B_MSF_H_
  19.  
  20. #include <qstring.h>
  21. #include <qregexp.h>
  22.  
  23. #include <kdebug.h>
  24. #include <kio/global.h>
  25. #include "k3bdevice_export.h"
  26.  
  27. namespace K3b
  28. {
  29.   /**
  30.    * int values are always treated as frames
  31.    * except in the set methods
  32.    * A MSF is never < 0.
  33.    */
  34.   class LIBK3BDEVICE_EXPORT Msf
  35.     {
  36.     public:
  37.       Msf();
  38.       Msf( const Msf& );
  39.       Msf( int, int, int );
  40.       Msf( int );
  41.  
  42.       Msf& operator=( const Msf& );
  43.       Msf& operator=( int );
  44.       Msf& operator+=( const Msf& );
  45.       Msf& operator+=( int );
  46.       Msf& operator-=( const Msf& );
  47.       Msf& operator-=( int );
  48.       const Msf operator++( int );
  49.       Msf& operator++();
  50.       const Msf operator--( int );
  51.       Msf& operator--();
  52.  
  53.       int minutes() const { return m_minutes; }
  54.       int seconds() const { return m_seconds; }
  55.       int frames() const { return m_frames; }
  56.  
  57.       int totalFrames() const { return ( m_minutes*60 + m_seconds )*75 + m_frames; }
  58.       int lba() const { return totalFrames(); }
  59.  
  60.       //      operator int () const { return lba(); }
  61.  
  62.       void setValue( int m, int s, int f );
  63.  
  64.       void addMinutes( int m );
  65.       void addSeconds( int s );
  66.       void addFrames( int f );
  67.  
  68.       QString toString( bool showFrames = true ) const;
  69.  
  70.       KIO::filesize_t mode1Bytes() const;
  71.       KIO::filesize_t mode2Form1Bytes() const;
  72.       KIO::filesize_t mode2Form2Bytes() const;
  73.       KIO::filesize_t audioBytes() const;
  74.       KIO::filesize_t rawBytes() const;
  75.       unsigned long long pcmSamples() const { return lba()*588; }
  76.  
  77.       /**
  78.        * Convert a string representation into an Msf object.
  79.        *
  80.        * Valid strings include:
  81.        * \li 100       - treated as 100 frames
  82.        * \li 100:23    - treated as 100 minutes and 23 seconds
  83.        * \li 100:23:57 - treated as 100 minutes, 23 seconds, and 57 frames
  84.        * \li 100:23.57 - treated as 100 minutes, 23 seconds, and 57 frames
  85.        */
  86.       static Msf fromString( const QString&, bool* ok = 0 );
  87.  
  88.       /**
  89.        * @param ms seconds
  90.        * frames will be rounded up
  91.        */
  92.       static Msf fromSeconds( double ms );
  93.  
  94.       static QRegExp regExp();
  95.  
  96.     private:
  97.       void makeValid();
  98.       int m_minutes;
  99.       int m_seconds;
  100.       int m_frames;
  101.     };
  102.  
  103.   LIBK3BDEVICE_EXPORT Msf operator+( const Msf&, const Msf& );
  104.   LIBK3BDEVICE_EXPORT Msf operator+( const Msf&, int );
  105.   LIBK3BDEVICE_EXPORT Msf operator-( const Msf&, const Msf& );
  106.   LIBK3BDEVICE_EXPORT Msf operator-( const Msf&, int );
  107.   LIBK3BDEVICE_EXPORT bool operator==( const Msf&, const Msf& );
  108.   LIBK3BDEVICE_EXPORT bool operator!=( const Msf&, const Msf& );
  109.   LIBK3BDEVICE_EXPORT bool operator<( const Msf&, const Msf& );
  110.   LIBK3BDEVICE_EXPORT bool operator>( const Msf&, const Msf& );
  111.   LIBK3BDEVICE_EXPORT bool operator<=( const Msf&, const Msf& );
  112.   LIBK3BDEVICE_EXPORT bool operator>=( const Msf&, const Msf& );
  113.  
  114.   LIBK3BDEVICE_EXPORT kdbgstream& operator<<( kdbgstream&, const Msf& );
  115.   LIBK3BDEVICE_EXPORT inline kndbgstream& operator<<( kndbgstream &stream, const Msf& ) { return stream; }
  116. }
  117.  
  118. #endif
  119.